﻿using CPPEI.Coolzon.Event.Core;
using CPPEI.Coolzon.Event.NCL;
using CPPEI.Coolzon.Event.UI;
using CPPEI.Coolzon.Theme.Fashion.MainViewControl;
using CPPEI.Coolzon.UI.Event;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;

namespace CPPEI.Coolzon.Theme.Fashion
{
    public partial class MainView
    {
        /// <summary>
        /// 按钮变更事件
        /// </summary>
        /// <param name="event"></param>
        [Common.Subscribe]
        public void NavChange(FastionNavChangeEvent @event)
        {
            contentBg.Visibility = Visibility.Visible;

            UIElement viewElement = contentBg.FindName("view") as UIElement;
            if (viewElement != null)
            {
                contentBg.Children.Remove(viewElement);
                contentBg.UnregisterName("view");
            }

            UserControl userControl = null;
            switch (@event.NavName)
            {
                case "Scene selection":
                    userControl = _viewSelectScene;
                    _viewSelectScene.BindScene();
                    break;
                case "System function":
                    userControl = new MainViewControl.SystemFunction();
                    break;
                case "Free interaction":
                    jsControl.Visibility = Visibility.Visible;
                    contentBg.Visibility = Visibility.Hidden;
                    break;
                case "Lecture notes":
                    userControl = new SpeechComment();
                    break;
            }
            if (userControl != null)
            {
                userControl.HorizontalAlignment = HorizontalAlignment.Center;
                userControl.VerticalAlignment = VerticalAlignment.Top;
                userControl.Margin = new Thickness(0, 41, 0, 0);
                contentBg.RegisterName("view", userControl);
                if (!contentBg.Children.Contains(userControl))
                {
                    contentBg.Children.Add(userControl);
                }
            }
        }
        /// <summary>
        /// 关闭中间内容事件
        /// </summary>
        /// <param name="event"></param>
        [Common.Subscribe]
        public void OnCloseCenterContent(CloseNavEvent @event)
        {
            contentBg.Visibility = Visibility.Hidden;
        }

        [Common.Subscribe]
        public void OnReceiveUIShowMagnifierEvent(Event.UI.UIShowMagnifierEvent @event)
        {
            if(@event.IsEnable)
            {
                _ctlMagnifierAlert.Visibility = System.Windows.Visibility.Visible;
            }
            else
            {
                _ctlMagnifierAlert.Visibility = System.Windows.Visibility.Hidden;
            }
        }

        [Common.Subscribe]
        public void OnReceiveUIShowLaserPointEvent(Event.UI.UIShowLaserPointEvent @event)
        {
            if(@event.IsEnable)
            {
                _ctlLaserPointAlert.Visibility = System.Windows.Visibility.Visible;
            }
            else
            {
                _ctlLaserPointAlert.Visibility = System.Windows.Visibility.Hidden;
            }
        }
    }
}
